import React, { useEffect, useState } from 'react'
import 'antd/dist/antd.less'
import HeaderNav from "./component/header/header"
import Login from './component/login/login';
import { Layout } from 'antd';
import { Route, Routes } from 'react-router-dom';
import { Bank, Competition, Discuss, Home, Learning, AppDown, User, Problem } from "./view"

const { Header, Content } = Layout;

function App() {
  const [visible, setVisible] = useState(true) 


  const close = () => {
    setVisible(false);
  }
  const clickLogin = ()=>{
    setVisible(true);
  }
  const onSignOut = ()=>{
    localStorage.removeItem("token") 
    localStorage.removeItem("authorId")
    setVisible(true);
  }

  
  return (
    <Layout style={{ backgroundColor: "white"}}>
      <Header style={{height:"50px",backgroundColor:"white", padding:"0 20px",borderBottom:"1px solid #e1e1e1"}}>
        <HeaderNav onClick={clickLogin} onSignOut={onSignOut} />
      </Header>
      <Layout style={{backgroundColor:"rgb(247, 248, 250)"}}>
        <Content>
          <Routes>
            <Route path="/" element={<Home />} />
            <Route path="/bank"  element={<Bank />} />
            <Route path="/bank/:id/*" element={<Problem  /> } />
            <Route path="/app" element={<AppDown />} />
            <Route path="/competition" element={<Competition />} />
            <Route path="/discuss" element={<Discuss />} />
            <Route path="/learning" element={<Learning />} />
            <Route path="/user" element={<User />} />
          </Routes>
        </Content>
        {/* <Sider>Sider</Sider> */}
        
      </Layout>
      {
        localStorage.getItem("token")==null ? <Login visible={visible} onCancel={close} />:""
      }  
    </Layout>
  );
}

export default App
